﻿using System;
using System.Data;
using System.Collections.Generic;
using HY.Model.CO;
namespace HY.BLL.CO
{
    /// <summary>
    /// comp_tel[电
    /// </summary>
    public partial class comp_tel
    {
        private readonly HY.DAL.CO.comp_tel dal = new HY.DAL.CO.comp_tel();
        public comp_tel()
        { }
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int sid)
        {
            return dal.Exists(sid);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(HY.Model.CO.comp_tel model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(HY.Model.CO.comp_tel model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int sid)
        {

            return dal.Delete(sid);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string sidlist)
        {
            return dal.DeleteList(sidlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public HY.Model.CO.comp_tel GetModel(int sid)
        {

            return dal.GetModel(sid);
        }

      
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<HY.Model.CO.comp_tel> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<HY.Model.CO.comp_tel> DataTableToList(DataTable dt)
        {
            List<HY.Model.CO.comp_tel> modelList = new List<HY.Model.CO.comp_tel>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                HY.Model.CO.comp_tel model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new HY.Model.CO.comp_tel();
                    if (dt.Rows[n]["sid"] != null && dt.Rows[n]["sid"].ToString() != "")
                    {
                        model.sid = int.Parse(dt.Rows[n]["sid"].ToString());
                    }
                    if (dt.Rows[n]["pbh"] != null && dt.Rows[n]["pbh"].ToString() != "")
                    {
                        model.pbh = dt.Rows[n]["pbh"].ToString();
                    }
                    if (dt.Rows[n]["pname"] != null && dt.Rows[n]["pname"].ToString() != "")
                    {
                        model.pname = dt.Rows[n]["pname"].ToString();
                    }
                    if (dt.Rows[n]["cbh"] != null && dt.Rows[n]["cbh"].ToString() != "")
                    {
                        model.cbh = dt.Rows[n]["cbh"].ToString();
                    }
                    if (dt.Rows[n]["cname"] != null && dt.Rows[n]["cname"].ToString() != "")
                    {
                        model.cname = dt.Rows[n]["cname"].ToString();
                    }
                    if (dt.Rows[n]["tel"] != null && dt.Rows[n]["tel"].ToString() != "")
                    {
                        model.tel = dt.Rows[n]["tel"].ToString();
                    }
                    if (dt.Rows[n]["person"] != null && dt.Rows[n]["person"].ToString() != "")
                    {
                        model.person = dt.Rows[n]["person"].ToString();
                    }
                    if (dt.Rows[n]["pmemo"] != null && dt.Rows[n]["pmemo"].ToString() != "")
                    {
                        model.pmemo = dt.Rows[n]["pmemo"].ToString();
                    }
                    if (dt.Rows[n]["pdtime"] != null && dt.Rows[n]["pdtime"].ToString() != "")
                    {
                        model.pdtime = DateTime.Parse(dt.Rows[n]["pdtime"].ToString());
                    }
                    if (dt.Rows[n]["sdtime"] != null && dt.Rows[n]["sdtime"].ToString() != "")
                    {
                        model.sdtime = DateTime.Parse(dt.Rows[n]["sdtime"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            return dal.GetRecordCount(strWhere);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  Method
    }
}

